/**
* @mxmlc -output=bin/assets/modules/report.swf -external-library-path+=lib/library.swc -debug=false -noplay
*/
package report 
{
	import com.greensock.easing.Bounce;
	import com.greensock.easing.Quart;
	import com.greensock.TweenLite;
	import flash.display.Bitmap;
	import morn.core.handlers.Handler;
	import org.airmvc.View;
	import report.view.PlotCase;
	import vo.GeneralVO;
	
	/**
	 * ...
	 * @author WLDragon 2014-02-28
	 */
	public class ReportV extends View 
	{
		
		public function ReportV(){}
		
		override public function init():void 
		{			
			incidentBmp = new Bitmap();
			incidentBmp.visible = false;
			addChild(incidentBmp);
			
			plotCase = new PlotCase();
			plotCase.visible = false;
			addChild(plotCase);
			
			Lyr.ui.addChild(this);
		}
		
		override protected function addListeners():void 
		{
			receive(ReportC.PLAY_INCIDENT,playIncident);
			receive(ReportC.PLAY_PLOT_CASE,playPlotCase);
		}
		
		private function playPlotCase(id:int,g:GeneralVO,callBack:Handler):void 
		{
			plotFun = callBack;
			plotCase.update(id, g);
			plotCase.visible = true;
			plotCase.bmpPanel.scaleX = 0;
			plotCase.bmpPanel.scaleY = 0;
			TweenLite.to(plotCase.bmpPanel,1.4,{scaleX:1,scaleY:1,ease:Quart.easeOut,onComplete:plotComplete});
		}
		
		private function plotComplete():void 
		{
			plotCase.visible = false;
			plotFun.execute();
		}
		
		private function playIncident(url:String,callBack:Function = null,tx:int = 0,ty:int = 0):void 
		{
			if (url == null)
			{
				incidentBmp.visible = false;
			}
			else
			{
				incidentFun = callBack;
				incidentBmp.x = tx;
				incidentBmp.y = -224;
				incidentBmp.bitmapData = App.asset.getBitmapData("png.report." + url);
				incidentBmp.visible = true;
				
				TweenLite.to(incidentBmp, 1, {y:ty, ease:Bounce.easeOut, onComplete:incidentComplete});
			}
		}
		
		private function incidentComplete():void 
		{
			incidentFun.call();
		}

		
		/**活动事件动画*/
		private var incidentBmp:Bitmap;
		private var incidentFun:Function;
		/**计谋事件*/
		private var plotCase:PlotCase;
		private var plotFun:Handler;
	}
	
}